package com.bao.interkont.controller;

import com.bao.interkont.pojo.Article;
import com.bao.interkont.pojo.Result;
import com.bao.interkont.utils.AliOSSUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author bao*
 * @version 1.0
 */
@Slf4j
@RestController
public class UpLoadController {
    @Autowired
    private AliOSSUtils aliOSSUtils;

    @PostMapping("/files/upload")
    public Result uploadCover(MultipartFile image) throws Exception{
        log.info("测试，{}",image);
        String url = aliOSSUtils.upload(image);
        return Result.success(url);
    }

    @PostMapping("/files/delete")
    public Result deleteCover(@RequestBody Article article) {
        String s = aliOSSUtils.delImage(article.getCover());
        return Result.success(s);
    }
}
